package com.example.memosystem.activity.listen;

import android.annotation.SuppressLint;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;

public class TouchListen implements View.OnTouchListener{

    private EditText ed = null;
    public TouchListen(EditText ed)
    {
        this.ed = ed;
    }

    @SuppressLint("ClickableViewAccessibility")
    @Override
    public boolean onTouch(View v, MotionEvent event) {

        int start = ed.getWidth() - ed.getPaddingEnd() - ed.getPaddingRight();
        int end = ed.getWidth();
        float x = event.getX();
        boolean isButtonClicked = x>start&&x<end;
        if(isButtonClicked)
        {
            if(event.getAction() == MotionEvent.ACTION_UP)
            {
                ed.setText("");
                return true;
            }
        }

        return false;
    }
}
